package com.shenmazong.lambda;

/**
 * @program: server-java-demo
 * @description: LambdaTest1
 * @author: 亮子说编程
 * @create: 2020-10-19 14:17
 **/

@FunctionalInterface
interface MessageBuilder {
    String buildMessage();
}

public class LambdaTest2 {

    private static void log(int level, MessageBuilder builder) {
        if (level == 1) {
            // 实际上利用内部类 延迟的原理,代码不相关 无需进入到启动代理执行
            System.out.println(builder.buildMessage());
        }
    }

    public static void main(String[] args) {
        String msgA = "Hello";
        String msgB = "World";
        String msgC = "Java";
        log(1,()->{
            System.out.println("lambda 是否执行了");
            return msgA + msgB + msgC;
        });
    }
}
